package first.forHuaWei.贪心;

/**
 * @ClassName LC45
 * @description:
 * @author: 荣燊
 * @create: 2021-09-06 13:06
 **/
public class LC45 {
    // 跳跃游戏 II,求解最小的步数,中途是不会断的
    public static void main(String[] args) {

    }

    // 标准的贪心算法
    public static int jump(int[] nums) {
        int step = 0;
        int position = nums.length-1;
        while (position > 0) {
            for (int i=0; i<position; i++) {
                if (i+nums[i] >= position) {
                    position = i;
                    step++;
                    break;
                }
            }
        }
        return step;
    }
}
